﻿namespace com.stifel.BranchMgmt
{
    using System.Collections.Generic;

    using com.stifel.BranchMgmtDao;
    using com.stifel.Extensions.SharePointExtensions;

    using Microsoft.SharePoint;

    public partial class BranchMgmtViewUserControl
    {
        #region Fields

        List<uiHardware_Data> _uiHardware_Data_List;

        #endregion Fields

        #region Properties

        List<uiHardware_Data> uiHardware_Data_List
        {
            get
            {
                if ( _uiHardware_Data_List == null )
                    _uiHardware_Data_List = new List<uiHardware_Data>( );
                return _uiHardware_Data_List;
            }
            set
            {
                _uiHardware_Data_List = value;
            }
        }

        #endregion Properties

        #region Methods

        void loadHardware( int branchId )
        {
            StifelHardwareDao dao = new StifelHardwareDao( SPContext.Current.Web.Url );
            List<StifelHardware> l = dao.GetByBranchLocation( branchId );
            foreach ( StifelHardware o in l )
                uiHardware_Data_List.Add( new uiHardware_Data( o ) );
            uiHardware_Repeater.DataSource = uiHardware_Data_List;
            uiHardware_Repeater.DataBind( );
        }

        #endregion Methods

        #region Nested Types

        protected class uiHardware_Data
        {
            #region Constructors

            public uiHardware_Data( StifelHardware value )
            {
                Title = value.Title;
                Type = value.HardwareTypeLookupId.HasValue ? value.HardwareTypeLookupTitle : string.Empty;
                Note = value.HardwareNote;
                ScheduledMaintenance = value.HasScheduledMaintenance && value.ScheduledMaintenance.HasValue ? value.ScheduledMaintenance.Value.ToShortDateString( ) : string.Empty;
            }

            #endregion Constructors

            #region Properties

            public string Note
            {
                get;
                set;
            }

            public string ScheduledMaintenance
            {
                get;
                set;
            }

            public string Title
            {
                get;
                set;
            }

            public string Type
            {
                get;
                set;
            }

            public string value
            {
                get;
                set;
            }

            #endregion Properties
        }

        #endregion Nested Types
    }
}